home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2002 September / PCpro_2002_09.ISO / techtalk / automationsuite / 247setup.exe / {app} / Template / get_exit_code.ini < prev    next >
Encoding:
INI File  |  2002-07-11  |  3.5 KB  |  85 lines

  1. ; Note: comment lines in .INI files always start with a semicolon
  2.  
  3. [Template]
  4. Description=Use this template to create a job that every day will start certain process at certain time. The job will check the exit code of the process and send an email alert if the exit code matches certain value. 
  5.  
  6. [Variables]
  7. ; Key values that have their name enclosed in % signs will be used for 
  8. ; template wizard questionnaire and substitution variables
  9. ; such key values should consist of 2 comma separated parts:
  10. ;    1. Field Edit Style (EDIT, YES/NO, FILE BROWSE, 
  11. ;                         DIR BROWSE, PROCESS BROWSE,
  12. ;                         FTP BROWSE, MAIL PROFILE LIST,
  13. ;                         REMOTE FILE BROWSE, REMOTE DIR BROWSE,
  14. ;                         REMOTE AGENT LIST, DB PROFILE LIST)
  15. ;    2. Prompt
  16. ;
  17. ; Example: %VAR%=EDIT,What is the name of the service that you want to monitor?
  18. ;
  19. ; Key values that don't have their name enclosed in % signs will be used for 
  20. ; job properties (See online help on "Job property names for use with JDL commands" 
  21. ; topic for more details).
  22. ;
  23. ; Example: DAY_NUMBER=1
  24.  
  25. %PROGRAM%=FILE BROWSE,Which program do you want to schedule?
  26. %START_TIME%=EDIT,Enter job start time (hh:mm in 24-hour time format):
  27. %EXIT_CODE%=EDIT,Enter the exit code that you want to trap:
  28. %EMAIL_RECIPIENT%=EDIT,To whom do you want to sent the email alert in case if the job fails or the exit code matches the value specified above:
  29. %EMAIL_PROFILE%=MAIL PROFILE LIST,If you use MAPI email interface, then which email profile do you want to use? If you use Lotus Notes or SMTP email interfaces, enter User ID required for logging to your email system.
  30. %EMAIL_PASSWORD%=EDIT,If you are required to login to your email system, what is your password:
  31. JOB_TYPE=S
  32. SCHEDULE_TYPE=D
  33. START_TIME=%START_TIME%
  34. SUNDAY=Y
  35. SATURDAY=Y
  36. SKIP_HOLIDAY=N
  37. SKIP=N
  38. ASYNC=Y
  39. MSG_ERROR=Y
  40. MSG_EMAIL=Y
  41. MSG_ACCOUNT=%EMAIL_PROFILE%
  42. MSG_PASSWORD=%EMAIL_PASSWORD%
  43. MSG_RECIPIENT=%EMAIL_RECIPIENT%
  44. DESCRIPTION=Every day this job kicks off the <insert process name here> process. 
  45.  
  46. ; Notes: The script bellow can include substitution variables.
  47. ;        Substitution variables must be specified in %VAR% format 
  48. ;        where VAR is the variable name.
  49. ;
  50. ; Everything after the next line will be used for the template script.
  51. ;========================================================================================
  52. [Body]
  53.  
  54. Dim process_id, number
  55. Dim exit_code, number
  56.  
  57. // Start process and wait for it to finish
  58. // 0 timeout means we can wait to infinity 
  59. RunAndWait "%PROGRAM%", "", 0, process_id
  60. // Get process exit code
  61. ProcessGetExitCode exit_code
  62.  
  63. // if exit code <> 0 then error occurred, otherwise exit
  64. ChooseCase exit_code, END_CHOOSE
  65. Case 0
  66.     // process finished successfully
  67. Case -1
  68.     // raise error and notify recipient
  69.     RaiseError "File %PROGRAM% not found"
  70. Case %EXIT_CODE%
  71.     // notify recipient that program terminated with the trappable exit code
  72.     MailSend "%EMAIL_PROFILE%", "%EMAIL_PASSWORD%", "%RECIPIENT%", &
  73.         "Job Execution Error", &
  74.         "Job: @V"job_name"\r\nProgram: %PROGRAM%\r\nExit Code: %EXIT_CODE%"
  75. CaseElse
  76.     // program terminated with non-zero return code which is different
  77.     // from the one we want to trap.
  78.     // Just in case, add the warning to the 24x7 event log
  79.     Dim message, string
  80.     Concat "Program %PROGRAM% terminated with non-zero exit code. Exit code: ", exit_code, message
  81.     LogAddMessageEx @V"job_id", @V"job_name", "WARNING", message
  82. END_CHOOSE:
  83.  
  84.  
  85.